package com.huluobo.a2307douyindemo.demo.viewbinding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding

/**
 *  Created by LC on 2025/9/11.
 */
abstract class BaseActivity2<T : ViewBinding> : AppCompatActivity() {
    //声明一个通用类型的binding
    protected lateinit var binding: T

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //在创建的时候来给binding赋值
        //赋值的内容需要重写,也就是具体继承后的Activity的xml布局
        binding = getViewBinding()
        setContentView(binding.root)

        initView()
        initData()
    }

    abstract fun initData()

    abstract fun initView()

    //所有继承的activity必须要重写的方法,提供一个ActivityBinding的inflate
    abstract fun getViewBinding(): T
}